<template>
	<v-select v-model="data" v-bind="$attrs" :items="items" :loading="loading" multiple :disabled="disabled"/>
</template>

<script>
import MdMVVMObject from '@/common/mixins/MdMVVMObject';
import RoleApi from '@/common/api/RoleApi';
export default {
	name: 'MdRoleSelector',
	mixins: [MdMVVMObject],
	data() {
		return {
			items: [],
			search: undefined
		}
	},
	computed: {},
	created() {
		this.getData();
	},
	methods: {
		getData() {
			this.loading = true;
			RoleApi.list().then(res => {
				this.$utils.responseHandler(res).then(({data}) => {
					if (!data) {
						data = [];
					}
					this.items = data.map(item => {
						return {
							text: item.displayName,
							value: item.id
						}
					})
				})
			}).finally(() => this.loading = false)
		}
	},
	filters: {},
	watch: {
	}
}
</script>

<style scoped lang="scss">

</style>